package cn.dnf.feignClient;

import cn.dnf.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFallbackFactory implements FallbackFactory<UserFeignClient> {

    //此方法帮我们创建降级类
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L,"熔断了","稍后重试");
            }

        };
    }
}
